/*
 * @lc app=leetcode.cn id=367 lang=csharp
 *
 * [367] 有效的完全平方数
 */

// @lc code=start
public class Solution {
    public bool IsPerfectSquare(int num) {
        if (num == 1) return true;
        long left = 1, right = num / 2;
        while (left <= right)
        {
            long mid = left + (right - left) / 2;
            long square = mid * mid;
            if (square == num) return true;
            if (square < num) left = mid + 1;
            else right = mid - 1;
        }
        return false;
    
    }
}
// @lc code=end

